<?php

//$email_to="fauglobe@qq.com,abans@qq.com,abans@abans.cn";
/*
$email_to=array(
	array('email'=>'108054989@qq.com','name'=>'108054989'),
	array('email'=>'fauglobe@qq.com','name'=>'fauglobe'),
);
$email_subject="测试主题";
$email_message="测试内容";
if(sendmailAll($email_to, $email_subject, $email_message))
	echo '发送成功';
else
	echo '发送失败';
*/
function asendmailall($tomail,$title,$body,$type=null,$frommail=null,$fromname=null){
	if($frommail==null){
		$frommail = 'abans@abans.cn';
	}
	if($fromname==null){
		$fromname = 'abans.cn';
	}
	if($type==null){
		$type = 'text/html';
	}
	foreach($tomail as $key=>$val){
		if(empty($header_to)){
			$header_to = $val['name']." <".$val['email'].">";
		}else{
			$header_to .= ', '.$val['name']." <".$val['email'].">";
		}
	}
	//-----指定邮件类型
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: '.$type.'; charset=utf-8' . "\r\n";
	$headers .= 'To: '.$header_to. "\r\n";//接受者
	$headers .= 'From: '.$fromname.' <'.$frommail.'>' . "\r\n";//发件人
//	$headers .= 'Cc: abans@abans.cn' . "\r\n";//抄送
//	$headers .= 'Bcc: abans@163.com' . "\r\n";//未知

	if(mail("",$title,$body,$headers)){
		return true;
	}else{
		return false;
	}
}

function asendmail($tomail,$toname,$title,$body,$type=null,$frommail=null,$fromname=null){
	if($frommail==null){
		$frommail = 'abans@abans.cn';
	}
	if($fromname==null){
		$fromname = 'abans.cn';
	}
	if($type==null){
		$type = 'text/html';
	}
	
	$header_to = $toname." <".$tomail.">";
	
	//-----指定邮件类型
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: '.$type.'; charset=utf-8' . "\r\n";
	$headers .= 'To: '.$header_to. "\r\n";//接受者
	$headers .= 'From: '.$fromname.' <'.$frommail.'>' . "\r\n";//发件人
//	$headers .= 'Cc: abans@abans.cn' . "\r\n";//抄送
//	$headers .= 'Bcc: abans@163.com' . "\r\n";//未知
	if(mail("",$title,$body,$headers)){
		return true;
	}else{
		return false;
	}
}


?>